﻿using System;
using System.Collections;
using System.Diagnostics;

using Microsoft.Build.Framework;

namespace KubertSoft.MSBuildTasks.Subversion.Tests
{
    /// <summary>
    /// The stub for the Build Engine.
    /// </summary>
    public class BuildEngineStub : IBuildEngine
    {
        /// <summary>
        /// Builds the project file.
        /// </summary>
        /// <param name="projectFileName">Name of the project file.</param>
        /// <param name="targetNames">The target names.</param>
        /// <param name="globalProperties">The global properties.</param>
        /// <param name="targetOutputs">The target outputs.</param>
        /// <returns><true> if build success; <c>false</c> otherwise.</true></returns>
        public bool BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs)
        {
            return false;
        }

        /// <summary>
        /// Gets the errors count.
        /// </summary>
        /// <value>The errors count.</value>
        public int ErrorsCount { get; private set; }

        /// <summary>
        /// Gets the line number of the task node within the project file that called it.
        /// </summary>
        /// <value></value>
        /// <returns>
        /// The line number of the task node within the project file that called it.
        /// </returns>
        public int ColumnNumberOfTaskNode
        {
            get { return 0; }
        }

        /// <summary>
        /// Returns true if the ContinueOnError flag was set to true for this particular task in the project file.
        /// </summary>
        /// <value></value>
        /// <returns>true if the ContinueOnError flag was set to true for this particular task in the project file.
        /// </returns>
        public bool ContinueOnError
        {
            get { return false; }
        }

        /// <summary>
        /// Gets the line number of the task node within the project file that called it.
        /// </summary>
        /// <value></value>
        /// <returns>
        /// The line number of the task node within the project file that called it.
        /// </returns>
        public int LineNumberOfTaskNode
        {
            get { return 0; }
        }

        /// <summary>
        /// Raises a custom event to all registered loggers.
        /// </summary>
        /// <param name="e">The event data.</param>
        public void LogCustomEvent(CustomBuildEventArgs e)
        {
            Debug.Write("Event: ");
            Debug.WriteLine(e.Message);
        }

        /// <summary>
        /// Raises an error event to all registered loggers.
        /// </summary>
        /// <param name="e">The event data.</param>
        public void LogErrorEvent(BuildErrorEventArgs e)
        {
            Debug.Write("Error: ");
            Debug.WriteLine(e.Message);
            ErrorsCount++;
        }

        /// <summary>
        /// Raises a message event to all registered loggers.
        /// </summary>
        /// <param name="e">The event data.</param>
        public void LogMessageEvent(BuildMessageEventArgs e)
        {
            Debug.Write("Message: ");
            Debug.WriteLine(e.Message);
        }

        /// <summary>
        /// Raises a warning event to all registered loggers.
        /// </summary>
        /// <param name="e">The event data.</param>
        public void LogWarningEvent(BuildWarningEventArgs e)
        {
            Debug.Write("Warning: ");
            Debug.WriteLine(e.Message);
        }

        /// <summary>
        /// Gets the full path to the project file that contained the call to this task.
        /// </summary>
        /// <value></value>
        /// <returns>
        /// The full path to the project file that contained the call to this task.
        /// </returns>
        public string ProjectFileOfTaskNode
        {
            get { return String.Empty; }
        }
    }
}
